function formatFun(val,row){
    return '<a href="javascript:void(0)"  onclick="clickProductFun('+row.id+');" >'+val+'</a>';
}
function clickProductFun(id) {
    $("#productDetail").find("td").parent().remove();
    $.get("/invite/getDetail.do",{invteId:id},function (data) {
        var htms = '';
        for(var i=0;i<data.length;i++){
            for(var key in data[i]){
                console.log(key+':'+data[i][key]);
                var sign = data[i][key];
                htms+='<tr><td rowspan="'+sign.length+'">'+key+'</td>'
                for(var a=0;a<sign.length;a++){
                    htms+='<td>'+sign[a].name+'</td><td>'+sign[a].des+'</td><td>'+sign[a].significance+'</td><td>'+sign[a].price+'</td></tr>';
                }
            }
        }
        $("#productDetail").append(htms);
    });
    $("#Detail_dialog").dialog("open");
}

function cancelPush(){
    var selectrow = $("#invite_datagrid").datagrid("getSelected");
    $.ajax({
        type: "POST",
        dataType: "JSON",
        url:"/invite/cancelPush.do",
        data: {"productId": selectrow.id},
        success: function(data){
            data=$.parseJSON(data);
            if(data.success){
                $.messager.show({
                    title: "成功",msg:"操作成功!",
                    timeout:600,style:"left:30%;top:10%",
                    showType:"fade"
                });
                $("#companyProduct_datagrid").datagrid("reload");
            }else{
                $.messager.alert( "失败", data.msg,"error");
            }
        }
    });
}
//搜索企业
function compSearch(value) {
    var queryParams = {};
    queryParams.compName = value;
    var options = $("#invite_datagrid").datagrid('getPager').data("pagination").options;
    options.pageNumber = 1;
    //重新加载
    $("#invite_datagrid").datagrid('options').queryParams = queryParams;
    $("#invite_datagrid").datagrid('reload');
}

//联动处理classifyID处理Label
function rowOnchange(id) {
    var queryParams = {};
    queryParams.inviteId = id;
    //重新加载体检卡列表
    var options = $("#offer_datagrid").datagrid('getPager').data("pagination").options;
    options.pageNumber = 1;
    $("#offer_datagrid").datagrid('options').queryParams = queryParams;
    $("#offer_datagrid").datagrid('reload');
}

//撤销报价
function cancelOffer(){
    var selectrow = $("#offer_datagrid").datagrid("getSelected");
    if(selectrow==null){$.messager.alert("提示","请选择一个报价","info");return;}
    $.ajax({
        type: "POST",
        dataType: "JSON",
        url:"/invite/cancelOffer.do",
        data: {"offerId": selectrow.id},
        success: function(data){
            if(data.success){
                $.messager.show({
                    title: "成功",msg:"操作成功!",
                    timeout:600,style:"left:30%;top:10%",
                    showType:"fade"
                });
                $("#offer_datagrid").datagrid("reload");
            }else{
                $.messager.alert( "失败", data.msg,"error");
            }
        }
    });
}
//确认报价
function okOffer(){
    var selectrow = $("#offer_datagrid").datagrid("getSelected");
    if(selectrow==null){$.messager.alert("提示","请选择一个报价","info");return;}
    $.ajax({
        type: "POST",
        dataType: "JSON",
        url:"/invite/okOffer.do",
        data: {"offerId": selectrow.id},
        success: function(data){
            if(data.success){
                $.messager.show({
                    title: "成功",msg:"操作成功!",
                    timeout:600,style:"left:30%;top:10%",
                    showType:"fade"
                });
                $("#offer_datagrid").datagrid("reload");
                $("#invite_datagrid").datagrid("reload");
            }else{
                $.messager.alert( "失败", data.msg,"error");
            }
        }
    });
}